package com.njuse.jvmfinal.Instruction;

import java.nio.ByteBuffer;

import com.njuse.jvmfinal.runtimestructure.Jframe;

public class FCMPG extends Instruction {
	
	public  void readindex(ByteBuffer reader) {
		//no need to read
	}
	
	public  void execute(Jframe frame) {
		int top=frame.getStacktop();
		Object[] stack=frame.getManagestack();
        Object temp2=stack[top-1];
        Object temp1=stack[top-2];
        top=top-2;
        try {
        	float value1=Float.intBitsToFloat((int)temp1);  
        	float value2=Float.intBitsToFloat((int)temp2);  
        	
        	if (value1>value2) {
        		stack[top]=1;
        	}else if (value1==value2){
        		stack[top]=0;
        	}else {
        		stack[top]=-1;
        	}
        	top++;
        	frame.setManagestack(stack);
        	frame.setStacktop(top);
        }catch(Exception e) {
        	stack[top]=1;
        	top++;
        	frame.setManagestack(stack);
        	frame.setStacktop(top);
        }
	}
}
